// export function formatTime(dateString: string) {
//   const date = new Date(dateString);

//   // 获取年、月、日、小时、分钟、秒
//   const year = date.getUTCFullYear();
//   const month = String(date.getUTCMonth() + 1).padStart(2, "0"); // 月份从0开始，需要加1
//   const day = String(date.getUTCDate()).padStart(2, "0");
//   const hours = String(date.getUTCHours()).padStart(2, "0");
//   const minutes = String(date.getUTCMinutes()).padStart(2, "0");

//   // 组合成所需格式
//   return `${year}-${month}-${day} ${hours}:${minutes}`;
// }
export function formatTime(timestamp: string): string {
  // 将字符串形式的时间戳转换为数字，并乘以 1000 转换为毫秒
  const timeInMilliseconds = parseInt(timestamp, 10) * 1000;
  console.log(timeInMilliseconds);

  // 创建 Date 对象
  const date = new Date(timeInMilliseconds);

  // 获取年、月、日、小时、分钟、秒
  const year = date.getUTCFullYear();
  const month = String(date.getUTCMonth() + 1).padStart(2, "0"); // 月份从 0 开始，需要加 1
  const day = String(date.getUTCDate()).padStart(2, "0");
  const hours = String(date.getUTCHours()).padStart(2, "0");
  const minutes = String(date.getUTCMinutes()).padStart(2, "0");
  const seconds = String(date.getUTCSeconds()).padStart(2, "0");

  // 组合成所需格式：YYYY-MM-DD HH:MM:SS
  return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
}
